package xyz.cerberu.cet.search.server.impl;

import xyz.cerberu.cet.anime.domain.Anime;
import xyz.cerberu.cet.resource.domian.Resource;
import xyz.cerberu.cet.search.dao.SearchDao;
import xyz.cerberu.cet.search.server.SearchService;
import xyz.cerberu.cet.search.utils.IKAnalyzerUtils;
import xyz.cerberu.cet.subtitle.domain.Subtitle;

import java.util.List;

/**
 * @author β世界
s * Created on 21:27
 * @Description
 */
public class SearchServiceImpl implements SearchService {
    private final SearchDao searchDao;

    public SearchServiceImpl(SearchDao searchDao) {
        this.searchDao = searchDao;
    }

    /**
     * @author β世界 on 22:31 2020/6/8
     * 将搜索内容分词处理，并且根据页码进行搜索查询
     * @param search: 搜索信息
     * @param pageNumber: 当前页
     * @return java.util.List<com.Cet.anime.domain.Anime>
     **/
    @Override
    public List<Anime> searchAnime(String search, int pageNumber) {
        // 将搜索自己分词
        List<String> divide = IKAnalyzerUtils.Analyzer(search);
        // 查询相关的动漫
        return searchDao.selectAnimeByAnalyzer(divide);
    }

    @Override
    public List<Resource> searchResource(String search, int pageNumber) {
        // 将搜索自己分词
        List<String> divide = IKAnalyzerUtils.Analyzer(search);
        return searchDao.searchResourceBySearchList(divide);
    }

    @Override
    public List<Subtitle> searchSubtitle(String search, int pageNumber) {
        return null;
    }
}
